#!/bin/bash

cmd="mysql -uroot -p${MYSQL_ROOT_PASSWORD}"
if [[ -z $MYSQL_HOST ]];then
	MYSQL_HOST='%'
fi
$cmd -e "CREATE USER 'cmdb'@'${MYSQL_HOST}' IDENTIFIED BY '${MYSQL_PASSWORD}';"
$cmd -e "GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO '${MYSQL_USER}'@'%';"
$cmd -e "FLUSH PRIVILEGES;"
